#!/bin/sh
web_stat_log=manager_monitor.log
mails=$1
if [ ! -f $web_stat_log ]; then
   touch $web_stat_log
fi
website="10.171.127.219"
url="http://$website/login"
server_status_code=`curl -I -m 10 -o /dev/null -s -w %{http_code} "$url"`
if [ "$server_status_code" = "200" ]; then 
	echo "`date '+%Y-%m-%d %H:%M:%S'` visit $website status code 200 OK" >>$web_stat_log
else 
	echo "`date '+%Y-%m-%d %H:%M:%S'` visit $website error!!! server can't connect at 10s or stop response at 10 s, send mail ..." >> $web_stat_log
	echo "`date '+%Y-%m-%d %H:%M:%S'` visit $website error!!! server can't connect at 10s or stop response at 10 s" | mail -s "monitor $website" $mails
fi
exit 0
